/**
 * jims
 */
package com.jims.master.modules.sync.service;

import java.util.List;

import com.jims.master.common.web.impl.BaseDto;
import com.jims.master.modules.sync.dao.NetHisLoggerDao;
import com.jims.master.modules.sync.entity.ClinicMaster;
import com.jims.master.modules.sync.entity.NetHisLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jims.master.common.persistence.Page;
import com.jims.master.common.service.CrudService;

/**
 * Service
 * @author WangYQ
 * @version 2018-03-29
 */
@Service
@Transactional(readOnly = true)
public class NetHisLoggerService extends CrudService<NetHisLoggerDao, NetHisLogger> {
	@Autowired
	private ClinicMasterService clinicMasterService;

	public NetHisLogger get(String id) {
		return super.get(id);
	}
	
	public List<NetHisLogger> findList(NetHisLogger netHisLogger) {
		return super.findList(netHisLogger);
	}
	
	public Page<NetHisLogger> findPage(Page<NetHisLogger> page, NetHisLogger netHisLogger) {
		return super.findPage(page, netHisLogger);
	}
	
	@Transactional(readOnly = false)
	public int save(NetHisLogger netHisLogger) {
		return super.save(netHisLogger);
	}
	
	@Transactional(readOnly = false)
	public int delete(NetHisLogger netHisLogger) {
		return super.delete(netHisLogger);
	}
	/**
	 * @Description: 保存传输返回的记录
	 * @param clinicMaster
	 * @param baseDto
	 * @author WangYQ
	 * @date 2018/03/29
	 * @throws
	 */
	@Transactional(readOnly = false)
	public int save(ClinicMaster clinicMaster, BaseDto baseDto){
		clinicMaster.setHisFlag("1");
		clinicMasterService.save(clinicMaster);
		NetHisLogger netHisLogger=new NetHisLogger();
		netHisLogger.setClinicId(clinicMaster.getId());
		netHisLogger.setDoctorId(clinicMaster.getDoctorId());
		netHisLogger.setPatientId(clinicMaster.getBaseInfo());
		netHisLogger.setStatus(baseDto.get("warnCode").toString());
		netHisLogger.setRemarks(baseDto.get("message").toString());
		return this.save(netHisLogger);
	}
}